#include "Enemy.h"

void Enemy::Set()
{
	_Coordinate._x = rand() % WindowWidth;
	_Coordinate._y = rand() % WindowHeight;

	_r = 10;

	_Speed._x = rand() % 10 - 5;
	_Speed._y = rand() % 10 - 5;
	
	_timer.SetTime(30);
	_timer.Start();
}

void Enemy::Move()
{
	if (_timer.IsTimeOut())
	{
		_Coordinate += _Speed;
		if (_Coordinate._x < 0)_Coordinate._x = WindowWidth;
		if (_Coordinate._x > WindowWidth)_Coordinate._x = 0;
		if (_Coordinate._y < 0)_Coordinate._y = WindowHeight;
		if (_Coordinate._y > WindowHeight)_Coordinate._y = 0;
	}
}


void Enemy::Draw(HDC hdc)
{
	HBRUSH hBrushBlue = CreateSolidBrush(RGB(0, 0, 255));
	HBRUSH hBrush = (HBRUSH)SelectObject(hdc, hBrushBlue);

	Ellipse(hdc,
		int(_Coordinate._x - _r), int(_Coordinate._y - _r),
		int(_Coordinate._x + _r), int(_Coordinate._y + _r)
	);

	SelectObject(hdc, hBrush);
	DeleteObject(hBrushBlue);
}
